//
//  CommendTableOut.m
//  XRmenu-HD
//
//  Created by shengchao yang on 11-12-26.
//  Copyright (c) 2011年 home user. All rights reserved.
//

#import "CommendTableOut.h"
#import "CommendTable.h"
@interface CommendTableOut(Private) 
-(void) subviewAppear;
-(void) subviewDisappear;
@end

#define kTagOfStartCommendViewOut 5820

@implementation CommendTableOut
-(id) initWithStyle:(NSString *)stylename ViewName:(NSString *)vname
{
    self = [super initWithStyle:stylename DishSubViewName:vname];
    if (self) {  
        [self setClipsToBounds:YES];//规定所有子view里的动画必须在当前view里进行
        
        //实例化CommendTable对象
        CommendTable *ctv=[[CommendTable alloc] initWithStyle:APPSESSION.uistyle ViewName:@"Commend View/CommendTable View"];
        ctv.tag=kTagOfStartCommendViewOut;
        ctv.hidden=YES;
        [self addSubview:ctv];
        [ctv release];
    }
    return self;
}
-(void) checkSubviewAppear{
    if ([self viewWithTag:kTagOfStartCommendViewOut]) {
        if ([self viewWithTag:kTagOfStartCommendViewOut].hidden) {
            [self subviewAppear];
        }
        else{
            [self subviewDisappear];
        }
    }
}
//显示子view的动画效果
-(void) subviewAppear{
    [self viewWithTag:kTagOfStartCommendViewOut].tag=kTagOfStartCommendViewOut+1;
    [[self viewWithTag:kTagOfStartCommendViewOut+1] slideInFrom:kFTAnimationTop inView:self.superview  duration:0.3f delegate:self startSelector:@selector(movingIn) stopSelector:@selector(resetTag)];
}
-(void) movingIn{
    [self viewWithTag:kTagOfStartCommendViewOut+1].hidden=NO;
    self.hidden=NO;
}
-(void) resetTag{//在动画完成后恢复tag的值
    [self viewWithTag:kTagOfStartCommendViewOut+1].tag=kTagOfStartCommendViewOut;
}

//移除子view的动画效果
-(void) subviewDisappear{
    [self viewWithTag:kTagOfStartCommendViewOut].tag=kTagOfStartCommendViewOut+1;
    [[self viewWithTag:kTagOfStartCommendViewOut+1] slideOutTo:kFTAnimationTop inView:self.superview  duration:0.3f delegate:self startSelector:nil stopSelector:@selector(movingOut)];
}
-(void) movingOut{
    [self viewWithTag:kTagOfStartCommendViewOut+1].hidden=YES;
    self.hidden=YES;
    [self viewWithTag:kTagOfStartCommendViewOut+1].tag=kTagOfStartCommendViewOut;
}
//=========================================================== 
// dealloc
//=========================================================== 
- (void)dealloc
{
    [super dealloc];
}
@end
